<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #al{
      width: 500px;
      height: 500px;
      background-color: aqua;
    }
    #bl{
      width: 300px;
      height: 300px;
      background-color: red;
    }
    #cl{
      width: 100px;
      height: 100px;
      background-color: gold;
    }
  </style>
</head>
<body>
  <div id="al">
    <div id="bl">
      <div id="cl"></div>
    </div>
  </div><script></script>
  <script>
    var al = document.getElementById("al");
    var bl = document.getElementById("bl");
    var cl = document.getElementById("cl");
    var ll = [al,bl,cl];
    for (let index = 0; index < ll.length; index++) {
      ll[index].onclick = function (e) {
        e = e || window.event
        console.log(this.id);
        // 阻止事件冒泡
        e.stopPropagation()
      }
    }
  </script>
</body>
</html>